define(
    function (require) {
        require('tpl!./form.tpl.html');

        var u = require('underscore');
        var ubRiaUtil = require('ub-ria/util');

        var BaseFormView = require('common/FormView');

        function FormView() {
            BaseFormView.apply(this, arguments);
        }

        FormView.prototype.template = 'foodNewProductForm';

        FormView.prototype.enterDocument = function() {
            BaseFormView.prototype.enterDocument.apply(this, arguments);
            var uploaders = ['pic'];
            u.each(
                uploaders,
                function (uploaderId) {
                    var me = this;
                    (function (id) {
                        var uploader = me.get(id + '-uploader');
                        uploader.on(
                            'onecomplete',
                            function (event) {
                                me.fire(id + '-upload', event);
                            }
                        );
                    }(uploaderId));
                },
                this
            );
        };

        /**
         * 从表单中获取实体数据
         *
         * @return {Object}
         */
        FormView.prototype.getEntity = function () {
            var entity = BaseFormView.prototype.getEntity.apply(this, arguments);
            return entity;
        };

        require('er/util').inherits(FormView, BaseFormView);
        return FormView;
    }
);
